package com.huike.clues.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.xiaoymin.knife4j.core.util.StrUtil;
import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.dto.TbClueDTO;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.TbClueService;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.service.TbClueTrackRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.AccessType;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 93238
 * @description 针对表【tb_clue(线索)】的数据库操作Service实现
 * @createDate 2023-10-12 06:35:46
 */
@Service
public class TbClueServiceImpl extends ServiceImpl<TbClueMapper, TbClue>
        implements TbClueService {
    @Autowired
    private TbClueTrackRecordService tbClueTrackRecordService;
    @Autowired
    private TbClueMapper tbClueMapper;

    /**
     * 查询列表
     *
     * @param dto
     * @return
     */
    @Override
    public List<TbClue> selectById(TbClueDTO dto) {

        List<TbClue> list = this.lambdaQuery()
                .like(dto.getId() != null, TbClue::getId, dto.getId())
                .like(StrUtil.isNotBlank(dto.getPhone()), TbClue::getPhone, dto.getPhone())
                .eq(StrUtil.isNotBlank(dto.getChannel()), TbClue::getChannel, dto.getChannel())
                .ge(dto.getCreateTime() != null, TbClue::getCreateTime, dto.getCreateTime())
                .le(dto.getEndTime() != null, TbClue::getEndTime, dto.getEndTime())
                .eq(StrUtil.isNotBlank(dto.getStatus()), TbClue::getStatus, dto.getStatus())
                .list();
        return list;

    }

    /**
     * 分页查询线索池
     *
     * @param dto
     * @return
     */
    @Override
    public List<TbClue> selectpool(TbClueDTO dto) {
        List<TbClue> list = this.lambdaQuery()
                .like(dto.getId() != null, TbClue::getId, dto.getId())
                .like(StrUtil.isNotBlank(dto.getPhone()), TbClue::getPhone, dto.getPhone())
                .eq(StrUtil.isNotBlank(dto.getChannel()), TbClue::getChannel, dto.getChannel())
                .ge(dto.getCreateTime() != null, TbClue::getCreateTime, dto.getCreateTime())
                .le(dto.getEndTime() != null, TbClue::getEndTime, dto.getEndTime())
                .list();
        return list;
    }
}




